Page({

  /**
   * 页面的初始数据
   */
  data: {
    content: '',
    flag: 0,
    flag0: 0,
    num:1,
    imageList: [],

    countIndex: 8,
    count: [1, 2, 3, 4, 5, 6, 7, 8, 9]
  },
  bindTextAreaBlur: function (e) {
    this.setData({
      content: e.detail.value
    })
  },
  sourceTypeChange: function (e) {
    this.setData({
      sourceTypeIndex: e.detail.value
    })
  },
  sizeTypeChange: function (e) {
    this.setData({
      sizeTypeIndex: e.detail.value
    })
  },
  countChange: function (e) {
    this.setData({
      countIndex: e.detail.value
    })
  },
  chooseImage: function () {
    var that = this;
    wx.chooseImage({
      count: 9 - that.data.imageList.length,
      success: function (res) {
        console.log(that.data.imageList)
        if(that.data.imageList.length){
          that.setData({
            imageList: that.data.imageList.concat(res.tempFilePaths)
          })
        }else{
          that.setData({
            imageList: res.tempFilePaths
          })
        } 
      }
    })
  },
  previewImage: function (e) {
    var current = e.target.dataset.src
    console.log(current)
    wx.previewImage({
      current: current,
      urls: this.data.imageList
    })
  },
  delete:function(e){
    var that = this;
    var Images = this.data.imageList;
    var index = e.currentTarget.dataset.index;
    console.log(Images +','+ index)
    Images.splice(index, 1);
    that.setData({
      imageList: Images
    });
  },
  changeColor1: function () {
    var that = this;
    that.setData({
      flag: 1
    });
  },
  changeColor2: function () {
    var that = this;
    that.setData({
      flag: 2
    });
  },
  changeColor3: function () {
    var that = this;
    that.setData({
      flag: 3
    });
  },
  changeColor4: function () {
    var that = this;
    that.setData({
      flag: 4
    });
  },
  changeColor5: function () {
    var that = this;
    that.setData({
      flag: 5
    });
  },
  changeOne: function () {
    var that = this;
    that.setData({
      flag0: 1
    });
  },
  changeTwo: function () {
    var that = this;
    that.setData({
      flag0: 2
    });
  },
  changeThree: function () {
    var that = this;
    that.setData({
      flag0: 3
    });
  },
  changeFour: function () {
    var that = this;
    that.setData({
      flag0: 4
    });
  },
  changeFif: function () {
    var that = this;
    that.setData({
      flag0: 5
    });
  }
})